using UnityEngine;

public class QLight : MonoBehaviour
{
	private UIToggle curTog;

	private void Awake()
	{
		curTog = GetComponent<UIToggle>();
	}

	private void OnEnable()
	{
		if (QualityController.instance != null)
		{
			QualityController.onChangeQuality += UpdateParameter;
		}
		UpdateParameter();
	}

	private void OnDisable()
	{
		if (QualityController.instance != null)
		{
			QualityController.onChangeQuality -= UpdateParameter;
		}
	}

	public void ChangeQuality()
	{
		if (QualityController.instance != null)
		{
			QualityController.LightEnable = curTog.value;
		}
	}

	private void UpdateParameter()
	{
		if (!(QualityController.instance != null))
		{
			return;
		}
		bool lightEnable = QualityController.LightEnable;
		if (lightEnable != curTog.value)
		{
			if (BCWDebug.isDebugBuild)
			{
				BCWDebug.Log("UpdateParameter light: " + lightEnable);
			}
			curTog.value = lightEnable;
		}
	}
}
